﻿using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Golos.Helper;

namespace Golos.Polls.PollCache
{
    public partial class Cache
    {
        public Cache()
        {
            lockcache = new object();
            UpCache();
        }

        private void UpCache()
        {
            LogClass.WriteInfoEntry("Start UpCache");
            lock (lockcache)
            {
                GetPollCacheFromDb();
                
            }
            LogClass.WriteInfoEntry(string.Format("End UpCache questionPolls.count={0}",questionPolls.Count));
        }

        private readonly object lockcache;
        //Key: userId Value: List<UserAnswerInfo>
        //private Dictionary<Guid, List<UserAnswerInfo>> userPolls;
        //Key: questionId Value: {Key: userId Value: UserAnswerInfo}
        private Dictionary<Guid, Dictionary<Guid, UserAnswerInfo>> questionUserAnswers;
        //Key: questionId Value: PollInfo
        private Dictionary<Guid, PollInfo> questionPolls;
        //Key: answerId Value: List<AnswerProperties>
        private Dictionary<Guid, List<AnswerProperties>> answerPropertiesCache;
        //Key: questionId Value: {Key: answerId Value: count}
        private Dictionary<Guid, Dictionary<Guid, int>> voicesCountCache;
        //Key: userId Value: List<QuestionId>
        private Dictionary<Guid, List<Guid>> userOwnerQuestions;
        //Key: userId Value: List<QuestionId>
        private Dictionary<Guid, List<Guid>> userVotedQuestions;
    }
}
